package com.jianganming.nio;

import java.nio.Buffer;
import java.nio.IntBuffer;

public class IntBufferDemo {
    public static void main(String[] args) {
        Buffer buffer = IntBuffer.allocate(5);

        for (int i = 0; i < buffer.capacity(); i++) {
            ((IntBuffer) buffer).put(i);
        }

        //指向初始位置
        buffer.flip();

        while (buffer.hasRemaining()){
            System.out.println(((IntBuffer) buffer).get());
        }

    }
}
